package com.dcrzl.shcz.common.excel;

import com.alibaba.excel.converters.date.DateStringConverter;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;

@Slf4j
public class MyDateStringConverter extends DateStringConverter {

    public MyDateStringConverter() {
    }

    @Override
    public WriteCellData<?> convertToExcelData(Date value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        log.info("ssssssss");
        String s = "";
        if (Objects.nonNull(value)) {
            log.info(value.toString());
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
            s = sdf.format(value);
        }
        return new WriteCellData<String>(s);
    }
}
